package com.ruoyi.teaching.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.teaching.vo.MyStageTaskVO;
import com.ruoyi.teaching.domain.YaStageTask;
import com.ruoyi.teaching.domain.YaStageTaskSubmit;
import com.ruoyi.teaching.service.IYaStageTaskService;
import com.ruoyi.teaching.service.IYaStageTaskSubmitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 阶段任务Controller
 *
 * @author ruoyi
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/my_stage_task")
public class YaMyStageTaskController extends BaseController
{
    @Autowired
    private IYaStageTaskService yaStageTaskService;
    @Autowired
    private IYaStageTaskSubmitService yaStageTaskSubmitService;

    /**
     * 查询阶段任务列表
     */
    @RequiresPermissions("teaching:my_stage_task:list")
    @GetMapping("/list")
    public TableDataInfo list(YaStageTask yaStageTask)
    {
        startPage();
        List<MyStageTaskVO> list = yaStageTaskService.selectMyStageTaskList(yaStageTask);
        return getDataTable(list);
    }


    @RequiresPermissions("teaching:my_stage_task:edit")
    @PutMapping
    public AjaxResult submit(@RequestBody YaStageTaskSubmit yaStageTaskSubmit)
    {
        yaStageTaskSubmitService.submit(yaStageTaskSubmit);
        return AjaxResult.success();
    }

}
